package net.easyjava.base.utils.http.cookie;

import net.easyjava.tools.cookie.CookieTools;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by wenxiaoning on 15/12/22.
 */
public class CookieUtils {
    public static final String DOMAIN = "wennspring.com";
    public static final int maxAge = 60 * 60;
    //储存用户id
    public static final String USESSIONID = "USESSIONID";


    /**
     * 保存USESSIONID
     * @param response
     * @param value
     */
    public static void saveUSessionId(HttpServletResponse response,String value){
        CookieTools.setCookie(response,USESSIONID,value,DOMAIN);
//        CookieTools.saveCookie(response,USESSIONID,value,maxAge,DOMAIN,true);
    }

    /**
     * 获取USESSIONID
     * @param request
     * @return
     */
    public static Cookie getUSessionId(HttpServletRequest request){
        return CookieTools.getCookie(request,USESSIONID);
    }

    public static void removeUSessionId(HttpServletRequest request,HttpServletResponse response){
        CookieTools.removeCookie(request,response,USESSIONID);
    }
}
